﻿using System;
using System.Collections.Generic;
using System.Text;
    public class Utils
    {
        public static string ToStr(object obj)
        {
            if (obj == null || string.IsNullOrEmpty(obj.ToString()))
                return string.Empty;
            else
                return Convert.ToString(obj);
        }
        public static DateTime ToDataTime(object obj)
        {
            try
            {
                DateTime da = Convert.ToDateTime(obj);
                return da;
            }
            catch (Exception ex)
            {
                return DateTime.Now;
            }
        }
        public static float ToFloat(object obj)
        {
            if (obj == null)
                return 0;
            float x = 0;
            float.TryParse(obj.ToString(), out x);
            return x;
        }
        public static int ToInt(object obj)
        {
            if (obj == null)
                return 0;
            int x = 0;
            int.TryParse(obj.ToString(), out x);
            return x;
        }
    }
